package com.weaver.drools.common.utils;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 *  数字工具
 *  @project: Absu_Blog
 *  @author: zhouxinlei
 *  @time：2018年8月9日
 *  @version：ver 1.1
 */
public class NumericUtilTools {


    public static boolean isNumeric(String str) {
        Pattern pattern = Pattern.compile("-?[0-9]+.?[0-9]+");
        Matcher isNum = pattern.matcher(str);
        return isNum.matches();
    }

    public static String formatNumeric(Double number) {
        DecimalFormat df = (DecimalFormat) NumberFormat.getInstance();
        df.setGroupingUsed(false);
        return df.format(number);
    }

    public static String formatNumericCurrency(Double number) {
        DecimalFormat df = (DecimalFormat) NumberFormat.getInstance();
        return df.format(number);
    }
}
